			
			
			/*  :====================================================================: 
				* 											Name			: Auto Enchant Weapon
				*											Create BY   	: KimeraTeam
				*											Email				: ryodan4@gmail.com
				*											MSN				: pthailan@hotmail.com  EnchantByKimera
				*
				:====================================================================:  */
				
package events.EnchantByKimera;

import java.util.Date;
//import com.l2jserver.gameserver.util.Util;

import com.l2jserver.Config;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.model.itemcontainer.PcInventory;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;

/* =========================== Create By : KimeraTeam ======================== */
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
import com.l2jserver.gameserver.network.serverpackets.UserInfo;

import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
//import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
//com/l2jserver/gameserver/model/itemcontainer/ItemContainer.java

//import com.l2jserver.gameserver.network.serverpackets.FlyToLocation;  

/* ======================Edit By : END KImeraTeam=========================== */
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;

import com.l2jserver.util.Rnd;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse; 

/**
 * Event Code for "Master of Enchanting"<br>
 * http://www.lineage2.com/archive/2009/06/master_of_encha.html
* @author Gnacik   
 */
public class EnchantByKimera extends Quest
{
	private static final int _kimera_en = 10003;
	private static final int _kimera_en_staff = 13539;
	private static final int _kimera_en_scroll = 13540;
	
	private static final int _staff_price = 1000000;
	private static final int _scroll_24_price = 5000000;
	private static final int _scroll_24_time = 6;
	
	private static final int _scroll_1_price = 500000;
	private static final int _scroll_10_price = 5000000;
	
	/* ======================================= Avarible By: KimeraTeam ===================== */
	
	private static final int _enchant_auto = Config.ENCHANT_SAFE_MAX; //5
	private static final int _adena_count = 100;
	/* private static final int _enchant_random_s = 5;
	private static final int _enchant_random_e = 15; */
	private static final int ItemCount = 30;
	private static final int ItemIdPrice = 1353; 
														
	
	/* private static final int[] weaponIds =
	{
		6611,6612,6613,6614,6615,6616,6617,6618,6619,6620,6621,9388,9389,9390
	}; */
	/* ======================================= End Avarible By: KimeraTeam ================== */
	//public static final  R_Hand_K ;
	
	private static final int[] _hat_shadow_reward =
	{
		13074, 13075, 13076
	};
	private static final int[] _hat_event_reward =
	{
		13518, 13519, 13522
	};
	private static final int[] _crystal_reward =
	{
		9570, 9571, 9572
	};
	
	@SuppressWarnings("deprecation")
	private static final Date _eventStart = new Date(2012, 7, 1);
	
	private static final Location[] _spawns =
	{
		new Location(16111, 142850, -2707, 16000),
		new Location(17275, 145000, -3037, 25000),
		new Location(83037, 149324, -3470, 44000),
		new Location(82145, 148609, -3468, 0),
		new Location(81755, 146487, -3534, 32768),
		new Location(-81031, 150038, -3045, 0),
		new Location(-83156, 150994, -3130, 0),
		new Location(-13727, 122117, -2990, 16384),
		new Location(-14129, 123869, -3118, 40959),
		new Location(-84411, 244813, -3730, 57343),
		new Location(-84023, 243051, -3730, 4096),
		new Location(46908, 50856, -2997, 8192),
		new Location(45538, 48357, -3061, 18000),
		new Location(9929, 16324, -4576, 62999),
		new Location(11546, 17599, -4586, 46900),
		new Location(81987, 53723, -1497, 0),
		new Location(81083, 56118, -1562, 32768),
		new Location(147200, 25614, -2014, 16384),
		new Location(148557, 26806, -2206, 32768),
		new Location(117356, 76708, -2695, 49151),
		new Location(115887, 76382, -2714, 0),
		new Location(-117239, 46842, 367, 49151),
		new Location(-119494, 44882, 367, 24576),
		new Location(111004, 218928, -3544, 16384),
		new Location(108426, 221876, -3600, 49151),
		new Location(-45278, -112766, -241, 0),
		new Location(-45372, -114104, -241, 16384),
		new Location(115096, -178370, -891, 0),
		new Location(116199, -182694, -1506, 0),
		new Location(86865, -142915, -1341, 26000),
		new Location(85584, -142490, -1343, 0),
		new Location(147421, -55435, -2736, 49151),
		new Location(148206, -55786, -2782, 61439),
		new Location(43165, -48461, -797, 17000),
		new Location(43966, -47709, -798, 49999)
	};
		
					
	
	public EnchantByKimera(int questId, String name, String descr)
	{
		
		super(questId, name, descr);
		addStartNpc(_kimera_en);
		addFirstTalkId(_kimera_en);
		addTalkId(_kimera_en);
		for (Location loc : _spawns)
		{
			addSpawn(_kimera_en, loc, false, 0);
		}
	}
	
	@Override
	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
	{
		String htmltext = event;
		QuestState st = player.getQuestState(getName());
		
		if (event.equalsIgnoreCase("buy_staff"))
		{
			if (!st.hasQuestItems(_kimera_en_staff) && (st.getQuestItemsCount(PcInventory.ADENA_ID) > _staff_price))
			{
				st.takeItems(PcInventory.ADENA_ID, _staff_price);
				st.giveItems(_kimera_en_staff, 1);
				htmltext = "32599-staffbuyed.htm";
			}
			else
			{
				htmltext = "32599-staffcant.htm";
			}
		}
		else if (event.equalsIgnoreCase("buy_scroll_24"))
		{
			long _curr_time = System.currentTimeMillis();
			String value = loadGlobalQuestVar(player.getAccountName());
			long _reuse_time = value == "" ? 0 : Long.parseLong(value);
			if (player.getCreateDate().after(_eventStart))
			{
				return "32599-bidth.htm";
			}
			
			if (_curr_time > _reuse_time)
			{
				if (st.getQuestItemsCount(PcInventory.ADENA_ID) > _scroll_24_price)
				{
					st.takeItems(PcInventory.ADENA_ID, _scroll_24_price);
					st.giveItems(_kimera_en_scroll, 24);
					saveGlobalQuestVar(player.getAccountName(), Long.toString(System.currentTimeMillis() + (_scroll_24_time * 3600000)));
					htmltext = "32599-scroll24.htm";
				}
				else
				{
					htmltext = "32599-s24-no.htm";
				}
			}
			else
			{
				long _remaining_time = (_reuse_time - _curr_time) / 1000;
				int hours = (int) _remaining_time / 3600;
				int minutes = ((int) _remaining_time % 3600) / 60;
				if (hours > 0)
				{
					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.ITEM_PURCHASABLE_IN_S1_HOURS_S2_MINUTES);
					sm.addNumber(hours);
					sm.addNumber(minutes);
					player.sendPacket(sm);
					htmltext = "32599-scroll24.htm";
				}
				else if (minutes > 0)
				{
					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.ITEM_PURCHASABLE_IN_S1_MINUTES);
					sm.addNumber(minutes);
					player.sendPacket(sm);
					htmltext = "32599-scroll24.htm";
				}
				else
				{
					// Little glitch. There is no SystemMessage with seconds only. 
					// If time is less than 1 minute player can buy scrolls
					if (st.getQuestItemsCount(PcInventory.ADENA_ID) > _scroll_24_price)
					{
						st.takeItems(PcInventory.ADENA_ID, _scroll_24_price);
						st.giveItems(_kimera_en_scroll, 24);
						saveGlobalQuestVar(player.getAccountName(), Long.toString(System.currentTimeMillis() + (_scroll_24_time * 3600000)));
						htmltext = "32599-scroll24.htm";
					}
					else
					{
						htmltext = "32599-s24-no.htm";
					}
				}
			}
		}
		else if (event.equalsIgnoreCase("buy_scroll_1"))
		{
			if (st.getQuestItemsCount(PcInventory.ADENA_ID) > _scroll_1_price)
			{
				st.takeItems(PcInventory.ADENA_ID, _scroll_1_price);
				st.giveItems(_kimera_en_scroll, 1);
				htmltext = "32599-scroll-ok.htm";
			}
			else
			{
				htmltext = "32599-s1-no.htm";
			}
		}
		
		/* :==================================: Start Helmet :==================================:  */
		else if (event.equalsIgnoreCase("enchant_helmet"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_HEAD) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_HEAD).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_HEAD).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_HEAD);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}					
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END HeaD :==================================:  */
		
		
		/* :==================================: Start Chest :==================================:  */
			else if (event.equalsIgnoreCase("enchant_chest"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_CHEST) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
				
									
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Chest :==================================:  */
		
		
		
		/* :==================================: Start Leggings :==================================:  */
			else if (event.equalsIgnoreCase("enchant_leggings"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_LEGS) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
				
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Leggings :==================================:  */
		
		
		
		/* :==================================: Start Gloves :==================================:  */
			else if (event.equalsIgnoreCase("enchant_gloves"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_GLOVES) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
								
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
				
							player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));				
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Gloves :==================================:  */
		
		
		
		/* :==================================: Start Boots :==================================:  */
			else if (event.equalsIgnoreCase("enchant_boots"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_FEET) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Boots :==================================:  */
		
		
		
		/* :==================================: Start Shirt :==================================:  */
			else if (event.equalsIgnoreCase("enchant_shirt"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_UNDER) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_UNDER).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________")); 
				} else{
							st.takeItems(PcInventory.ADENA_ID, _adena_count);		
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_UNDER).setEnchantLevel(_enchant_auto); 							
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_UNDER);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
				
									
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Shirt :==================================:  */
		
		
		/* :==================================: Start Weapon :==================================:  */
			else if (event.equalsIgnoreCase("enchant_weapon"))  
		{
		
			
			if ((st.getItemEquipped(Inventory.PAPERDOLL_RHAND) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{					
							
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).setEnchantLevel(_enchant_auto); 						
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);					
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));					
						    SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
				
							
						}			
				
								
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Weapon :==================================:  */
		
		
		/* :==================================: Start Upper Earring :==================================:  */ 
			else if (event.equalsIgnoreCase("enchant_upper_earring"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_LEAR) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEAR).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEAR).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEAR);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Upper Earring :==================================:  */
		
		
		
		/* :==================================: Start Lower Earring :==================================:  */
			else if (event.equalsIgnoreCase("enchant_lower_earring"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_REAR) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_REAR).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_REAR).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_REAR);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Lower Earring :==================================:  */
		
		
		/* :==================================: Start Nuckace :==================================:  */
			else if (event.equalsIgnoreCase("enchant_neckace"))  //enchant_neckace
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_NECK) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_NECK).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_NECK).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_NECK);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Nuckace :==================================:  */
		
		
		/* :==================================: Start Upper Ring :==================================:  */
			else if (event.equalsIgnoreCase("enchant_upper_ring"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_LFINGER) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LFINGER).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LFINGER).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LFINGER);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Upper Ring :==================================:  */
		
		
		/* :==================================: Start Lower Ring :==================================:  */
			else if (event.equalsIgnoreCase("enchant_lower_ring"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_RFINGER) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RFINGER).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RFINGER).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RFINGER);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Lower Ring :==================================:  */
		
		
		/* :==================================: Start Belt :==================================:  */
			else if (event.equalsIgnoreCase("enchant_belt"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_BELT) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_BELT).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{
							st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_BELT).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_BELT);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Belt :==================================:  */
		
		
		/* :==================================: Start Shield :==================================:  */
			else if (event.equalsIgnoreCase("enchant_shield"))  
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_LHAND) != 0))
			{
						
				if (st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND).getEnchantLevel() >= _enchant_auto)
				{
				player.sendPacket(SystemMessage.sendString("________ITEM มีค่าการบวกมากกว่า 4 แล้ว________"));
				} else{st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND).setEnchantLevel(_enchant_auto); 
							final L2ItemInstance item = st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND);						
							player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));												
							SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.C1_SUCCESSFULY_ENCHANTED_A_S2_S3);
							sm.addCharName(player);
							sm.addNumber(item.getEnchantLevel());
							sm.addItemName(item);
							player.broadcastPacket(sm);
				            player.sendPacket(new UserInfo(player));
						}			
							
							htmltext = "10003-enchant-4.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Shield :==================================:  */
		
		
		
		
		/* :==================================: Start Weapon Random  Enchant 0-15 :==================================:  */
			else if (event.equalsIgnoreCase("enchant_weapon_random"))  
		{
						
			if ((st.getItemEquipped(Inventory.PAPERDOLL_RHAND) != 0))
			{										
				if (st.getQuestItemsCount(ItemIdPrice) < ItemCount)
				
				{
				player.sendPacket(SystemMessage.sendString("________ท่านมีไอเทมที่ข้าต้องการไม่เพียงพอ________"));		
				} 
				
			
				
				else{		
							/* =================== New By Kimera  =================*/
							final int chance = Rnd.get(100);
							final int RndEn_1 = Rnd.get(1, 5);
							final int RndEn_2 = Rnd.get(6, 7);
							final int RndEn_3 = Rnd.get(8, 9);
							final int RndEn_4 = Rnd.get(10, 11);
							final int RndEn_5 = Rnd.get(12, 13);
							final int RndEn_6 = Rnd.get(13, 14);																												
																		
												 if (chance < 10)
												{			
												
												st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).setEnchantLevel(RndEn_1); 
												player.sendPacket(SystemMessage.sendString("________ท่านสุ่มบวกไอเทมได้ +"+RndEn_1+"________"));	
												st.takeItems(ItemIdPrice, ItemCount);	
												player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));
															InventoryUpdate iu = new InventoryUpdate();															
															player.sendPacket(iu);
															player.broadcastPacket(new CharInfo(player));
															player.sendPacket(new UserInfo(player));
															player.broadcastPacket(new ExBrExtraUserInfo(player));
												}					
																							
																							
												else if (chance < 15)
												{
												st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).setEnchantLevel(RndEn_2); 
												player.sendPacket(SystemMessage.sendString("________ท่านสุ่มบวกไอเทมได้ +"+RndEn_2+"________"));	
												st.takeItems(ItemIdPrice, ItemCount);	
												player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));
															InventoryUpdate iu = new InventoryUpdate();															
															player.sendPacket(iu);
															player.broadcastPacket(new CharInfo(player));
															player.sendPacket(new UserInfo(player));
															player.broadcastPacket(new ExBrExtraUserInfo(player));
												}
												
												else if (chance < 30)
												{
												st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).setEnchantLevel(RndEn_3); 
												player.sendPacket(SystemMessage.sendString("________ท่านสุ่มบวกไอเทมได้ +"+RndEn_3+"________"));	
												st.takeItems(ItemIdPrice, ItemCount);	
												player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));
															InventoryUpdate iu = new InventoryUpdate();															
															player.sendPacket(iu);
															player.broadcastPacket(new CharInfo(player));
															player.sendPacket(new UserInfo(player));
															player.broadcastPacket(new ExBrExtraUserInfo(player));
												}
												
												else if (chance < 50)
												{
												st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).setEnchantLevel(RndEn_4);
												player.sendPacket(SystemMessage.sendString("________ท่านสุ่มบวกไอเทมได้ +"+RndEn_4+"________"));	
												st.takeItems(ItemIdPrice, ItemCount);
												player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));
															InventoryUpdate iu = new InventoryUpdate();															
															player.sendPacket(iu);
															player.broadcastPacket(new CharInfo(player));
															player.sendPacket(new UserInfo(player));
															player.broadcastPacket(new ExBrExtraUserInfo(player));												
												}
												
												else if (chance < 80)
												{
												st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).setEnchantLevel(RndEn_5);
												player.sendPacket(SystemMessage.sendString("________ท่านสุ่มบวกไอเทมได้ +"+RndEn_5+"________"));
												st.takeItems(ItemIdPrice, ItemCount);	
												player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));
															InventoryUpdate iu = new InventoryUpdate();															
															player.sendPacket(iu);
															player.broadcastPacket(new CharInfo(player));
															player.sendPacket(new UserInfo(player));
															player.broadcastPacket(new ExBrExtraUserInfo(player));
												
												}
												
												else if (chance < 90)
												{
												st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).setEnchantLevel(RndEn_6);
												player.sendPacket(SystemMessage.sendString("________ท่านสุ่มบวกไอเทมได้ +"+RndEn_6+"________"));	
												st.takeItems(ItemIdPrice, ItemCount);	
												player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));
															InventoryUpdate iu = new InventoryUpdate();															
															player.sendPacket(iu);
															player.broadcastPacket(new CharInfo(player));
															player.sendPacket(new UserInfo(player));
															player.broadcastPacket(new ExBrExtraUserInfo(player));
												}
												
												else if (chance < 100)
												{
												st.getPlayer().getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).setEnchantLevel(15);
												player.sendPacket(SystemMessage.sendString("________ท่านสุ่มบวกไอเทมได้ +15________"));	
												st.takeItems(ItemIdPrice, ItemCount);
												player.broadcastPacket(new MagicSkillUse(player, player, 721, 1, 1000, 0));
															InventoryUpdate iu = new InventoryUpdate();															
															player.sendPacket(iu);
															player.broadcastPacket(new CharInfo(player));
															player.sendPacket(new UserInfo(player));
															player.broadcastPacket(new ExBrExtraUserInfo(player));
																
													   }
							
							
							
							/* =================== End New By Kimera  =================*/		
							
					
						}			
				
							player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));				
							htmltext = "10003.htm";
			}
			else
			{
				player.sendPacket(SystemMessage.sendString("________:" + player.getName() + "  โปรดใส่ ITEM ที่จะบวกด้วย :________"));
				player.sendPacket(SystemMessage.sendString("_____: ของคุณที่ใช้บริการกับ RDF ENCHANT :_____"));
				htmltext = "10003.htm";
			}
		}
		/* :==================================: END Weapon :==================================:  */
		
		
		

		
		else if (event.equalsIgnoreCase("buy_scroll_10"))
		{
			if (st.getQuestItemsCount(PcInventory.ADENA_ID) > _scroll_10_price)
			{
				st.takeItems(PcInventory.ADENA_ID, _scroll_10_price);
				st.giveItems(_kimera_en_scroll, 10);
				htmltext = "32599-scroll-ok.htm";
			}
			else
			{
				htmltext = "32599-s10-no.htm";
			}
		}
		else if (event.equalsIgnoreCase("receive_reward"))
		{
			if ((st.getItemEquipped(Inventory.PAPERDOLL_RHAND) == _kimera_en_staff) && (st.getEnchantLevel(_kimera_en_staff) > 3))
			{
				switch (st.getEnchantLevel(_kimera_en_staff))
				{
					case 4:
						st.giveItems(6406, 1); // Firework
						break;
					case 5:
						st.giveItems(6406, 2); // Firework
						st.giveItems(6407, 1); // Large Firework
						break;
					case 6:
						st.giveItems(6406, 3); // Firework
						st.giveItems(6407, 2); // Large Firework
						break;
					case 7:
						st.giveItems(_hat_shadow_reward[getRandom(3)], 1);
						break;
					case 8:
						st.giveItems(955, 1); // Scroll: Enchant Weapon (D)
						break;
					case 9:
						st.giveItems(955, 1); // Scroll: Enchant Weapon (D)
						st.giveItems(956, 1); // Scroll: Enchant Armor (D)
						break;
					case 10:
						st.giveItems(951, 1); // Scroll: Enchant Weapon (C)
						break;
					case 11:
						st.giveItems(951, 1); // Scroll: Enchant Weapon (C)
						st.giveItems(952, 1); // Scroll: Enchant Armor (C)
						break;
					case 12:
						st.giveItems(948, 1); // Scroll: Enchant Armor (B)
						break;
					case 13:
						st.giveItems(729, 1); // Scroll: Enchant Weapon (A)
						break;
					case 14:
						st.giveItems(_hat_event_reward[getRandom(3)], 1);
						break;
					case 15:
						st.giveItems(13992, 1); // Grade S Accessory Chest (Event)
						break;
					case 16:
						st.giveItems(8762, 1); // Top-Grade Life Stone: level 76
						break;
					case 17:
						st.giveItems(959, 1); // Scroll: Enchant Weapon (S)
						break;
					case 18:
						st.giveItems(13991, 1); // Grade S Armor Chest (Event)
						break;
					case 19:
						st.giveItems(13990, 1); // Grade S Weapon Chest (Event)
						break;
					case 20:
						st.giveItems(_crystal_reward[getRandom(3)], 1); // Red/Blue/Green Soul Crystal - Stage 14
						break;
					case 21:
						st.giveItems(8762, 1); // Top-Grade Life Stone: level 76
						st.giveItems(8752, 1); // High-Grade Life Stone: level 76
						st.giveItems(_crystal_reward[getRandom(3)], 1); // Red/Blue/Green Soul Crystal - Stage 14
						break;
					case 22:
						st.giveItems(13989, 1); // S80 Grade Armor Chest (Event)
						break;
					case 23:
						st.giveItems(13988, 1); // S80 Grade Weapon Chest (Event)
					default:
						if (st.getEnchantLevel(_kimera_en_staff) > 23)
						{
							st.giveItems(13988, 1); // S80 Grade Weapon Chest (Event)
						}
						break;
				}
				st.takeItems(_kimera_en_staff, 1);
				htmltext = "32599-rewardok.htm";
			}
			else
			{
				htmltext = "32599-rewardnostaff.htm";
			}
		}
		return htmltext;
	}
	
	@Override
	public String onFirstTalk(L2Npc npc, L2PcInstance player)
	{
		if (player.getQuestState(getName()) == null)
		{
			newQuestState(player);
		}
		return npc.getNpcId() + ".htm";
	}
	
	public static void main(String[] args)
	{
		new EnchantByKimera(-1, "EnchantByKimera", "events");
		System.out.println(":============================================================================:");
		System.out.println(":______________:System Enchant Create By KimeraTeam   [Thailand]:____________:");
		System.out.println(":______________:Email - ryodan4@gmail.com , MSN - pthailan@hotmail.com:______:");
		System.out.println(":______________:Telephone : +66-90-604-1207 , +66-83-129-1843 :______________:");
		System.out.println(":============================================================================:");
		//System.output.println(" Enchant By  Kimera  pthailan@hotmail.com");
	}
}
